package com.rs.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Component;

@Component
public class DateFormatUtil {
	public  String getDateString(Date d,String format){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.format(d);
	}
	
	public static String getDateStringw(Date d,String format){
		if (d == null) {
			return "";
		}
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.format(d);
	}
	
	 public Date getDate(String dates,String format) {
	        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);//注意月份是MM
	        Date date = null;
			try {
				date = simpleDateFormat.parse(dates);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			return date;
	    }
}
